#include "../include/main.h"

#include "../include/unrealhandler.h"

class MainWind;

MainWind* win;

class MainWind : public Main  {

    UnrealHandler* handler;
public:
    string cmd;
    MainWind(int* argc, char **argv[]): Main(argc, argv)    {
		int count=0;
		char** args= *argv;
        cmd="";
		string host;
		int port=3000;
		int controllerport;

		if(++count < *argc)
           host=args[count];
		if(++count < *argc)
            port=atoi(args[count]);
        controllerport = port+1;
        if(++count < *argc)
            controllerport=atoi(args[count]);
        if(++count < *argc)
            cmd=args[count];

        handler = new UnrealHandler(host, port, controllerport);
    }
    void runBots(){
        handler->runAll();
    }
    void run()
    {
        handler->win->show_all();
        if(cmd=="run")
            handler->runAll();
        if(cmd=="connect")
            handler->connect();
        Main::run(*handler->win);
    }
};

int main (int argc, char *argv[]){
    Glib::init();
    Gio ::init();
    if( ! g_thread_supported() )
        g_thread_init( NULL );

    MainWind kit(&argc, &argv);
    win = &kit;
    kit.run();
}

